// 活动json
const activityJson = '[{"id":1,"url":"https://gd-filems.dancf.com/gaoding/gaoding/34324/30550b7f-e288-4ffd-a98d-c2595f5fb3f6258287.jpg?x-oss-process=image/resize,w_2000,h_2000/interlace,1/format,avif","name":"双111活动","address":"南昌市东方米兰服饰商务广场","date":"2023/05/06-2023/06/06"},{"id":2,"url":"https://img.shetu66.com/2022/08/cutCoverImg/1663065743290621.jpg?x-oss-process=image/resize,h_900/format,webp","name":"双22活动2","address":"南昌市东方米兰服饰商务广场","date":"2023/05/06-2023/06/06"},{"id":3,"url":"https://img1.baidu.com/it/u=486868600,4169209462&fm=253&app=138&f=JPEG?w=800&h=1732","name":"双22活动23这是活动名称这是活动名称","address":"南昌市东方米兰服饰商务广场","date":"2023/05/06-2023/06/06"}]'
// 优惠券json
const couponJson =
	'[{"id":1,"price":3000,"fullPrice":1000,"name":"满减券","deadlineStart":"2024/10/12","deadlineEnd":"2024/11/12"},{"id":2,"price":3000,"fullPrice":1000,"name":"折扣券","deadlineStart":"2024/10/12","deadlineEnd":"2024/11/12"},{"id":3,"price":3000,"fullPrice":1000,"name":"这是券的名称这是券的名称这是券的名称这是券的名称","deadlineStart":"2024/10/12","deadlineEnd":"2024/11/12"}]'
// 商品json
const goodsJson =
	'[{"id":1,"price":3000,"url":"https://img.alicdn.com/bao/uploaded/i3/2055770076/O1CN01jEkYK61CQr2Na3EO7_!!0-saturn_solar.jpg","name":"我是商品","desc":"好衣服你知道"},{"id":2,"price":3000,"url":"https://img.alicdn.com/imgextra/i3/2187216215/O1CN01sEeK2J1vmWYkhJGxP_!!2187216215-0-alimamacc.jpg","name":"上哦民擦擦擦","desc":"商品介绍商品介绍商品介绍商品介绍"},{"id":3,"price":3000,"url":"https://img.alicdn.com/imgextra/i4/2187216215/O1CN01wJNoxl1vmWYmoUyrH_!!2187216215-0-alimamacc.jpg","name":"商品名称商品名称","desc":"商品介绍商品介绍商品介绍商品介绍"}]'

// 图表json
const chartJson =
	'[{"name":"一班","value":50},{"name":"二班","value":30},{"name":"三班","value":20},{"name":"四班","value":18},{"name":"五班","value":8}]'
// 表格json
const tablesJson =
	'{"tableColumns": [{ "title": "苹果","key": "a","align": "center" },{  "title": "橘子", "key": "b", "align": "center"}],"tableData": [{"a": "10000元/斤","b": "200元/斤"},{"a": "2200元/斤","b": "2300元/斤"}]}'
const agentJson =
	'[{"id":1,"image":"https://img1.baidu.com/it/u=1921586067,4095260117&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=800","name":"智能体1","desc":"智能体1描述智能体1描述智能体1描述智能体1描述"},{"id":2,"image":"https://img1.baidu.com/it/u=1921586067,4095260117&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=800","name":"智能体2","desc":"智能体2描述智能体2描述智能体2描述智能体2描述"},{"id":3,"image":"https://img1.baidu.com/it/u=1921586067,4095260117&fm=253&fmt=auto&app=120&f=JPEG?w=800&h=800","name":"智能体3","desc":"智能体3描述智能体3描述智能体3描述智能体3描述"}]'
// 店铺json
const shopJson =
	'[{"id":1,"image":"https://marketplace.canva.cn/EAF5TAr7Zfc/1/0/1600w/canva-LoBvGA2wjHA.jpg","name":"店铺名称1","desc":"店铺描述店铺描述店铺描述店铺描述"},{"id":2,"image":"https://t8.baidu.com/it/u=2676458980,1132146964&fm=193","name":"店铺名称2","desc":"店铺描述店铺描述店铺描述店铺描述"},{"id":3,"image":"https://img.yzcdn.cn/upload_files/2023/08/18/Fg7F4L2XLvTEY7ulnZ5TX5Snr_zw.png","name":"店铺名称3","desc":"店铺描述店铺描述店铺描述店铺描述"}]'
// 深度思考数据  markdown语法中  在内容前面加上 > 即可格式化深度思考的样式，，然后 \n\n 就可以结束
const deepThinkContentList = ['[SEEK]', "首", "先", "，", "我", "需", "要", "理", "解", "用", "户", "的", "具", "体", "需", "求", "。",
	"根",
	"据", "用",
	"户", "之", "前", "的", "对", "话", "历", "史", "，", "他", "曾", "提", "到", "过", "「", "深", "度", "思", "考", "的", "流", "式",
	"回", "答", "数", "组", "」", "，", "并", "希", "望", "结", "合", "动", "态", "生", "成", "和", "展", "示", "思", "考", "过", "程",
	"的", "数", "据", "结", "构", "。",
	"\n\n", "接", "下", "来", "，", "我", "需", "要", "查", "看", "用", "户", "提", "供", "的", "搜", "索", "结", "果", "。", "用",
	"户",
	"提", "供", "了", "多", "个", "网", "页", "，", "其", "中", "网", "页", "4", "和", "网", "页", "5", "提", "到", "了", "D", "e",
	"e", "p", "S", "e", "e", "k", "的", "深", "度", "思", "考", "功", "能", "，", "特", "别", "是", "网", "页", "4", "详", "细",
	"介", "绍", "了", "D", "e", "e", "p", "S", "e", "e", "k", "-", "R", "1", "模", "型", "的", "思", "维", "链", "生", "成",
	"过", "程", "，", "包", "括", "如", "何", "分", "步", "骤", "展", "示", "思", "考", "路", "径", "。", "\n\n", '[TEXT]'
]


// 查询历史消息 
export const getChatHistoryListMook = async (data) => {
	if (data.pagination.pageNum > 1) {
		return []
	}
	return [{
			key: '1',
			createTime: '2022-09-09 12:12:12',
			type: 1,
			content: '活动',
			contentType: 'text'
		},
		{
			key: '2',
			createTime: '2022-11-11 09:30:00',
			type: 2,
			content: '双11限时满减活动进行中',
			contentType: 'activity',
			contentAppendData: activityJson
		},
		{
			key: '3',
			createTime: '2023-02-14 18:45:23',
			type: 1,
			content: '优惠券',
			contentType: 'text'
		},
		{
			key: '4',
			createTime: '2023-06-18 15:20:18',
			type: 2,
			content: '好的，这是给你推荐的优惠券',
			contentType: 'coupon',
			contentAppendData: couponJson
		},
		{
			key: '3',
			createTime: '2023-02-14 18:45:23',
			type: 1,
			content: '商品',
			contentType: 'text'
		},
		{
			key: '5',
			createTime: '2023-09-21 11:11:11',
			type: 2,
			content: '【新品上架】衣服服装上线X1',
			contentType: 'goods',
			contentAppendData: goodsJson
		},
		{
			key: '3',
			createTime: '2023-02-14 18:45:23',
			type: 1,
			content: '图表',
			contentType: 'text'
		},
		{
			key: '6',
			createTime: '2024-01-01 00:05:00',
			type: 2,
			content: '好的这是趋势分析图',
			contentType: 'chart_1',
			contentAppendData: chartJson
		},
		{
			key: '333',
			createTime: '2023-02-14 18:45:23',
			type: 1,
			content: '表格',
			contentType: 'text'
		},
		{
			key: '622',
			createTime: '2024-01-01 00:05:00',
			type: 2,
			content: '好的这是表格',
			contentType: 'tables',
			contentAppendData: tablesJson
		},
		{
			key: '777',
			createTime: '2023-02-14 18:45:23',
			type: 1,
			content: '店铺',
			contentType: 'text'
		},
		{
			key: '888',
			createTime: '2023-02-14 18:45:23',
			type: 2,
			content: '店铺',
			contentType: 'shop',
			contentAppendData: shopJson
		},
		{
			key: '999',
			createTime: '2023-02-14 18:45:23',
			type: 1,
			content: '智能体',
			contentType: 'text'
		},
		{
			key: '1000',
			createTime: '2023-02-14 18:45:23',
			type: 2,
			content: '智能体',
			contentType: 'agent',
			contentAppendData: agentJson
		},
		{
			key: '7',
			createTime: '2024-03-15 14:30:00',
			type: 1,
			content: '查看最新库存数据表格',
			contentType: 'text'
		},
		{
			key: '9',
			createTime: '2024-12-25 10:00:00',
			type: 2,
			content: '系统维护通知：01:00-03:00暂停服务',
			contentType: 'text'
		},
		{
			key: '10',
			createTime: '2025-04-08 16:30:00',
			type: 2,
			content: " 已经为您生成了一张活泼可爱的小女孩的图片。 ![](https://img-baofun.zhhainiao.com/pcwallpaper_ugc/static/50706fe64cbbdddc2c8c99d27eb64d4d.jpeg?x-oss-process=image%2fresize%2cm_lfit%2cw_3840%2ch_2160) 希望这张图片符合您的期望！如果有任何其他需求或想要调整的地方，请随时告诉我。",
			contentType: 'text'
		}
	]
}

// 根据发送的消息文字返回消息数组
const getChatList = (message = '') => {
	if (message.includes('活动')) {
		const data = {
			type: 'activity',
			dataStr: activityJson
		}
		return {
			contentList: ["好", "的", "，", "这", "是", "活", "动", "："],
			jsonData: JSON.stringify(data),
			startStr: '[JSON]',
			endStr: '[DONE]',
		}
	} else if (message.includes('优惠券')) {
		const data = {
			type: 'coupon',
			dataStr: couponJson
		}
		return {
			contentList: ["好", "的", "，", "这", "是", "优", "惠", "券", "："],
			jsonData: JSON.stringify(data),
			startStr: '[JSON]',
			endStr: '[DONE]',
		}
	} else if (message.includes('商品')) {
		const data = {
			type: 'goods',
			dataStr: goodsJson
		}
		return {
			contentList: ["好", "的", "，", "这", "是", "商", "品", "："],
			jsonData: JSON.stringify(data),
			startStr: '[JSON]',
			endStr: '[DONE]',
		}
	} else if (message.includes('图表')) {
		const data = {
			type: 'chart_1',
			dataStr: chartJson
		}
		return {
			contentList: ["好", "的", "，", "这", "是", "图", "表", "："],
			jsonData: JSON.stringify(data),
			startStr: '[JSON]',
			endStr: '[DONE]',
		}
	} else if (message.includes('表格')) {
		const data = {
			type: 'tables',
			dataStr: tablesJson
		}
		return {
			contentList: ["好", "的", "，", "这", "是", "表", "格", "："],
			jsonData: JSON.stringify(data),
			startStr: '[JSON]',
			endStr: '[DONE]',
		}
	} else if (message.includes('图片')) {
		return {
			// https://img-baofun.zhhainiao.com/pcwallpaper_ugc/static/50706fe64cbbdddc2c8c99d27eb64d4d.jpeg?x-oss-process=image%2fresize%2cm_lfit%2cw_3840%2ch_2160
			contentList: [
				'已', '经', '为', '您', '生', '成', '了', '一', '张', '活', '泼', '可', '爱', '的', '小', '女', '孩', '的', '图',
				'片', '。', ' ![](https://img-baofun.zhhainiao.com/pcwallpaper',
				'_ugc/static/50706fe64cbbdddc2c8c99d27eb64d4d.jpeg',
				'?x-oss-process=image%2fresize%2cm_lfit%2cw', '_3840%2ch_2160)',
				'希', '望', '这', '张', '图', '片', '符', '合', '您', '的', '期', '望', '！',
				'如', '果', '有', '任', '何', '其', '他', '需', '求', '或', '想', '要', '调', '整', '的', '地', '方', '，',
				'请', '随', '时', '告', '诉', '我', '。'
			],
			jsonData: '',
			startStr: '[TEXT]',
			endStr: '[DONE]',
		}
	} else if (message.includes('智能体')) {
		return {
			contentList: ["好", "的", "，", "这", "是", "智", "能", "体", "："],
			jsonData: agentJson,
			startStr: '[JSON]',
			endStr: '[DONE]',
		}
	}else if (message.includes('店铺')) {
		return {
			contentList: ["好", "的", "，", "这", "是", "店", "铺", "："],
			jsonData: shopJson,
			startStr: '[JSON]',
			endStr: '[DONE]',
		}
	} else {
		return {
			contentList: ["可", "以", "问", ":", "活", "动", "、", "优", "惠", "券", "、", "商", "品", "、",
				"图", "表", "、", "表", "格", "、", "图", "片", "。", "这", "些", "关", "键", "词", "触", "发",
				"对", "应", "的", "回", "答", "，", "让", "你", "体", "验", "！",
			],
			jsonData: '',
			startStr: '[TEXT]',
			endStr: '[DONE]',
		}


	}

}

// WebSocket双向通信示例方法
export const WebSocketMook = () => {
	// 触发消息回调函数
	const emitMessage = (data, options = {}) => {
		let contentList = []
		const hasDeepThink = options.deepThink === true;
		const hasWebSearch = options.webSearch === true;
		
		console.log("Mock WebSocket 开始处理:", { hasDeepThink, hasWebSearch });
		
		if (data.startStr == '[TEXT]') {
			contentList = [data.startStr, ...data.contentList, data.endStr]
		} else {
			// json数据
			contentList = ['[TEXT]', ...data.contentList, data.startStr, data.jsonData, data.endStr]
		}
		
		// ✅ 修复：支持深度思考模式
		if (hasDeepThink) {
			console.log("启用深度思考模式");
			contentList = [...deepThinkContentList, ...contentList]
		}

		// 模拟延迟
		setTimeout(() => {
			console.log("Mock WebSocket 开始发送消息:", { totalMessages: contentList.length });
			
			contentList.forEach((item, index) => {
				setTimeout(() => {
					uni.$emit('socketTaskOnMessage', {
						data: item
					});
				}, index * 105);
			});
		}, hasDeepThink ? 3000 : 1000); // 深度思考模式延迟更久
	}

	return {
		onOpen: (fn) => {
			fn({
				data: '连接正常'
			});
		},
		// ✅ 修复：支持新的send方法签名，处理options参数
		send: (sendData) => {
			// 检查是否为有效的发送数据对象
			if (typeof sendData === 'object' && sendData.data) {
				// 返回成功信息
				if (sendData.success) {
					sendData.success();
				}
				
				// 拿到消息和选项
				const message = sendData.data;
				const options = sendData.options || {};
				
				console.log('Mock WebSocket 收到发送请求:', {
					message: message.substring(0, 50) + '...',
					deepThink: options.deepThink,
					webSearch: options.webSearch
				});

				// 返回示例消息
				const responseChunks = getChatList(message);
				emitMessage(responseChunks, options);
			}
		},
		close: (data) => {
			// 关闭成功回调
			const success = data.success;
			// 关闭失败回调
			const fail = data.fail;
			try {
				uni.$off('socketTaskOnMessage');
				success({
					msg: '关闭成功'
				});
			} catch (e) {
				fail(e)
			}
		},
		onMessage: (fn) => {
			uni.$on('socketTaskOnMessage', (data) => {
				fn(data);
			});
		}
	};
}



// 获取快速提问列表
export const getQuickQuestionList = async () => {
	return [{
			id: 1,
			name: '帮我查一下最新商品'
		},
		{
			id: 2,
			name: '帮我查一下最近会员数据图表'
		},
		{
			id: 3,
			name: '帮我查一下优惠券'
		},
		{
			id: 4,
			name: '帮我查一下618可以参加的一些优惠活动'
		},
		{
			id: 5,
			name: '帮我生成图片'
		},
		{
			id: 6,
			name: '帮我生成小女孩的图片'
		}
	]
}

// 测试深度思考功能的辅助函数
export const testDeepThinkFlow = () => {
	console.log('🧪 开始测试深度思考流程');
	console.log('📝 深度思考内容数组:', deepThinkContentList);
	
	// 验证标签顺序
	const firstTag = deepThinkContentList[0];
	const lastTag = deepThinkContentList[deepThinkContentList.length - 1];
	
	console.log('🏁 第一个标签:', firstTag);
	console.log('🏁 最后一个标签:', lastTag);
	
	if (firstTag === '[SEEK]' && lastTag === '[TEXT]') {
		console.log('✅ 深度思考标签顺序正确');
		return {
			success: true,
			message: '深度思考功能配置正确'
		};
	} else {
		console.log('❌ 深度思考标签顺序错误');
		return {
			success: false,
			message: '深度思考标签配置有误'
		};
	}
};

// 完整测试Mock WebSocket连接和深度思考流程
export const testMockWebSocketFlow = () => {
	console.log('🧪 开始完整测试Mock WebSocket流程');
	
	// 创建Mock WebSocket实例
	const mockWS = WebSocketMook();
	
	// 设置消息监听
	mockWS.onMessage((data) => {
		console.log('📨 收到Mock WebSocket消息:', data);
	});
	
	// 建立连接
	mockWS.onOpen((data) => {
		console.log('🔗 Mock WebSocket连接成功:', data);
		
		// 测试普通消息
		console.log('\n🧪 测试普通消息发送...');
		mockWS.send({
			data: '测试消息',
			success: () => console.log('✅ 普通消息发送成功'),
			fail: (error) => console.log('❌ 普通消息发送失败:', error)
		});
		
		// 等待一段时间后测试深度思考
		setTimeout(() => {
			console.log('\n🧪 测试深度思考消息发送...');
			mockWS.send({
				data: '深度思考测试',
				options: { deepThink: true },
				success: () => console.log('✅ 深度思考消息发送成功'),
				fail: (error) => console.log('❌ 深度思考消息发送失败:', error)
			});
		}, 1000);
	});
	
	return mockWS;
};

// 快速诊断工具
export const diagnoseMockIssues = () => {
	console.log('🔍 开始诊断Mock WebSocket问题...');
	
	// 检查uni对象
	console.log('1. 检查uni对象:', {
		hasUni: typeof uni !== 'undefined',
		hasEmit: typeof uni?.$emit === 'function',
		hasOn: typeof uni?.$on === 'function'
	});
	
	// 检查WebSocketMook函数
	console.log('2. 检查WebSocketMook函数:', {
		hasFunction: typeof WebSocketMook === 'function',
		functionLength: WebSocketMook.length
	});
	
	// 检查深度思考内容
	console.log('3. 检查深度思考内容:', {
		hasContent: Array.isArray(deepThinkContentList),
		contentLength: deepThinkContentList.length,
		firstTag: deepThinkContentList[0],
		lastTag: deepThinkContentList[deepThinkContentList.length - 1]
	});
	
	// 测试事件系统
	console.log('4. 测试uni事件系统...');
	const testEventName = 'testMockEvent_' + Date.now();
	let eventReceived = false;
	
	// 监听测试事件
	uni.$on(testEventName, (data) => {
		eventReceived = true;
		console.log('✅ uni事件系统正常:', data);
	});
	
	// 发送测试事件
	uni.$emit(testEventName, { test: 'success' });
	
	// 清理事件监听
	setTimeout(() => {
		uni.$off(testEventName);
		if (!eventReceived) {
			console.log('❌ uni事件系统异常：事件未被接收');
		}
	}, 100);
	
	console.log('🔍 诊断完成，请查看上面的输出结果');
};

// 完整的调试和排查工具
export const debugMockWebSocketComplete = () => {
	console.log('🔍 开始完整的Mock WebSocket调试流程...');
	
	// 第一步：验证基础环境
	console.log('\n1️⃣ 检查基础环境:');
	console.log('✅ uni对象:', {
		hasUni: typeof uni !== 'undefined',
		hasEmit: typeof uni?.$emit === 'function',
		hasOn: typeof uni?.$on === 'function'
	});
	
	console.log('✅ WebSocketMook函数:', {
		exists: typeof WebSocketMook === 'function',
		name: WebSocketMook.name
	});
	
	console.log('✅ 深度思考内容:', {
		isArray: Array.isArray(deepThinkContentList),
		length: deepThinkContentList.length,
		firstTag: deepThinkContentList[0],
		lastTag: deepThinkContentList[deepThinkContentList.length - 1]
	});
	
	// 第二步：测试WebSocketMook函数
	console.log('\n2️⃣ 测试WebSocketMook函数创建:');
	let mockWS;
	try {
		mockWS = WebSocketMook();
		console.log('✅ WebSocketMook实例创建成功:', {
			hasOnOpen: typeof mockWS.onOpen === 'function',
			hasOnMessage: typeof mockWS.onMessage === 'function',
			hasSend: typeof mockWS.send === 'function',
			hasClose: typeof mockWS.close === 'function'
		});
	} catch (error) {
		console.error('❌ WebSocketMook实例创建失败:', error);
		return false;
	}
	
	// 第三步：测试事件监听
	console.log('\n3️⃣ 测试WebSocket事件监听:');
	let messageReceived = false;
	let openReceived = false;
	
	// 设置消息监听
	mockWS.onMessage((data) => {
		messageReceived = true;
		console.log('📨 收到Mock消息:', data);
	});
	
	// 设置连接监听
	mockWS.onOpen((data) => {
		openReceived = true;
		console.log('🔗 Mock连接成功:', data);
		
		// 连接成功后测试发送消息
		console.log('\n4️⃣ 测试消息发送:');
		
		// 测试普通消息
		console.log('📤 发送普通测试消息...');
		mockWS.send({
			data: '普通测试消息',
			success: () => {
				console.log('✅ 普通消息发送成功回调');
			},
			fail: (error) => {
				console.error('❌ 普通消息发送失败:', error);
			}
		});
		
		// 延迟测试深度思考消息
		setTimeout(() => {
			console.log('📤 发送深度思考测试消息...');
			mockWS.send({
				data: '深度思考测试',
				options: { deepThink: true },
				success: () => {
					console.log('✅ 深度思考消息发送成功回调');
				},
				fail: (error) => {
					console.error('❌ 深度思考消息发送失败:', error);
				}
			});
		}, 2000);
	});
	
	// 等待一段时间后检查结果
	setTimeout(() => {
		console.log('\n5️⃣ 测试结果总结:');
		console.log('📊 测试结果:', {
			openReceived,
			messageReceived,
			mockInstanceValid: !!mockWS
		});
		
		if (!openReceived) {
			console.error('❌ 连接事件未触发，请检查onOpen实现');
		}
		if (!messageReceived) {
			console.error('❌ 消息事件未触发，请检查消息发送机制');
		}
		
		console.log('🔍 调试完成！请查看上面的输出来定位问题。');
	}, 10000); // 等待10秒查看结果
	
	return mockWS;
};

// 简化的即时测试功能
export const quickTestMockMessage = () => {
	console.log('⚡ 快速测试Mock消息发送...');
	
	// 监听测试事件
	const testEventName = 'quickTestEvent_' + Date.now();
	let eventReceived = false;
	
	uni.$on(testEventName, (data) => {
		eventReceived = true;
		console.log('✅ 快速测试成功，收到事件:', data);
	});
	
	// 发送测试事件
	uni.$emit(testEventName, { message: '测试消息', timestamp: Date.now() });
	
	// 检查结果
	setTimeout(() => {
		if (!eventReceived) {
			console.error('❌ 快速测试失败：uni事件系统异常');
		} else {
			console.log('✅ 快速测试通过：uni事件系统正常');
		}
		uni.$off(testEventName);
	}, 100);
};

// 专门测试深度思考功能的方法
export const testDeepThinkOnly = () => {
	console.log('🧠 开始专门测试深度思考功能...');
	
	// 创建Mock WebSocket实例
	const mockWS = WebSocketMook();
	
	// 设置消息监听
	let messageCount = 0;
	const receivedMessages = [];
	
	mockWS.onMessage((data) => {
		messageCount++;
		receivedMessages.push(data.data);
		console.log(`🧠 深度思考测试 - 收到消息 ${messageCount}:`, data.data);
		
		// 分析收到的消息
		if (data.data === '[SEEK]') {
			console.log('✅ 深度思考开始标签已收到');
		} else if (data.data === '[TEXT]') {
			console.log('✅ 深度思考结束标签已收到，即将开始正常回答');
		} else if (data.data === '[DONE]') {
			console.log('✅ 回答完成标签已收到');
			
			// 总结测试结果
			console.log('\n📊 深度思考测试结果总结:');
			console.log('收到消息总数:', messageCount);
			console.log('是否包含开始标签 [SEEK]:', receivedMessages.includes('[SEEK]'));
			console.log('是否包含结束标签 [TEXT]:', receivedMessages.includes('[TEXT]'));
			console.log('是否包含完成标签 [DONE]:', receivedMessages.includes('[DONE]'));
			
			const seekIndex = receivedMessages.indexOf('[SEEK]');
			const textIndex = receivedMessages.indexOf('[TEXT]');
			const doneIndex = receivedMessages.indexOf('[DONE]');
			
			if (seekIndex >= 0 && textIndex >= 0 && doneIndex >= 0) {
				const thinkContent = receivedMessages.slice(seekIndex + 1, textIndex);
				const answerContent = receivedMessages.slice(textIndex + 1, doneIndex);
				
				console.log('深度思考内容片段数:', thinkContent.length);
				console.log('正常回答内容片段数:', answerContent.length);
				console.log('深度思考样本内容:', thinkContent.slice(0, 5).join(''));
				console.log('正常回答样本内容:', answerContent.slice(0, 5).join(''));
				
				if (thinkContent.length > 0 && answerContent.length > 0) {
					console.log('🎉 深度思考功能测试通过！');
				} else {
					console.log('❌ 深度思考功能测试失败：内容缺失');
				}
			} else {
				console.log('❌ 深度思考功能测试失败：标签缺失');
			}
		}
	});
	
	// 建立连接
	mockWS.onOpen((data) => {
		console.log('🔗 深度思考测试连接成功:', data);
		
		// 发送启用深度思考的测试消息
		console.log('📤 发送深度思考测试消息...');
		mockWS.send({
			data: '请进行深度思考测试',
			options: { deepThink: true }, // 强制启用深度思考
			success: () => {
				console.log('✅ 深度思考测试消息发送成功');
			},
			fail: (error) => {
				console.error('❌ 深度思考测试消息发送失败:', error);
			}
		});
	});
	
	return mockWS;
};

// 验证深度思考内容结构的工具
export const validateDeepThinkStructure = () => {
	console.log('🔍 验证深度思考内容结构...');
	
	console.log('深度思考内容数组信息:', {
		isArray: Array.isArray(deepThinkContentList),
		length: deepThinkContentList.length,
		firstElement: deepThinkContentList[0],
		lastElement: deepThinkContentList[deepThinkContentList.length - 1]
	});
	
	// 检查关键标签
	const hasSeekTag = deepThinkContentList.includes('[SEEK]');
	const hasTextTag = deepThinkContentList.includes('[TEXT]');
	
	console.log('标签检查:', {
		hasSeekTag,
		hasTextTag,
		seekIndex: deepThinkContentList.indexOf('[SEEK]'),
		textIndex: deepThinkContentList.indexOf('[TEXT]')
	});
	
	if (hasSeekTag && hasTextTag) {
		const seekIndex = deepThinkContentList.indexOf('[SEEK]');
		const textIndex = deepThinkContentList.indexOf('[TEXT]');
		
		if (seekIndex === 0 && textIndex === deepThinkContentList.length - 1) {
			console.log('✅ 深度思考内容结构正确');
			return true;
		} else {
			console.log('❌ 深度思考内容结构错误：标签位置不正确');
			return false;
		}
	} else {
		console.log('❌ 深度思考内容结构错误：缺少必要标签');
		return false;
	}
};

